package mo.offer_special;

public class L009 {

    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int n = nums.length;
        int i = 0;
        int product = 1;
        int ans = 0;
        for (int j = 0; j < n; j++) {
            product *= nums[j];
            while (product >= k && j >= i) {
                product = product / nums[i];
                i++;
            }
            ans += j - i + 1;
        }
        return ans;
    }

    public static void main(String[] args) {
        L009 test = new L009();
        System.out.println(test.numSubarrayProductLessThanK(new int[]{1, 2, 3}, 0));
    }

}
